package com.ccys.common.third.aws.polly;

import com.ccys.common.util.StringUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 三方参数 读取当前包下的oss.properties
 * <p>
 * 当本地启动时，因为不存在file路径，所以会加载classpath；
 * 当jar启动时，若file路径不存在，会加载classpath；反之会加载file路径同时覆盖classpath路径下的内容；
 * ignoreResourceNotFound = true 一定要加上，否则找不到会报错。加上之后会忽略找不到的配置文件。
 *
 * @author Administrator
 */
@Component("pollyConstants")
@PropertySource(value = {"classpath:config/polly.properties", "file:./config/polly.properties", "file:./../config/polly.properties"}, ignoreResourceNotFound = true, encoding = "utf-8")
public class PollyConstants {

    public static String accessKeyId;

    public static String accessKeySecret;

    public static String region;


    @Value("${aws.polly.accessKeyId}")
    public void setAccessKeyId(String accessKeyId) {
        if (StringUtil.isNotBlank(accessKeyId)) {
            accessKeyId = accessKeyId.trim();
        }
        PollyConstants.accessKeyId = accessKeyId;
    }

    @Value("${aws.polly.accessKeySecret}")
    public void setAccessKeySecret(String accessKeySecret) {
        if (StringUtil.isNotBlank(accessKeySecret)) {
            accessKeySecret = accessKeySecret.trim();
        }
        PollyConstants.accessKeySecret = accessKeySecret;
    }

    @Value("${aws.polly.region}")
    public void setArn(String region) {
        if (StringUtil.isNotBlank(region)) {
            region = region.trim();
        }
        PollyConstants.region = region;
    }




}
